package com.falcon.controller.toolkit;

import com.falcon.domain.req.GenerateRequest;
import com.falcon.service.IJavaGeneratorService;
import com.falcon.mvc.base.IBaseController;
import com.falcon.mvc.domain.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("/toolkit/genJava")
@Tag(name = "1.java代码生成接口", description = "根据数据库表生成java对应的 po、mapper、controller等代码")
public class GenJavaController implements IBaseController {

    @Autowired
    private IJavaGeneratorService generatorService;

    @Operation(summary = "生成Java代码")
    @PutMapping()
    public BaseResponse<Boolean> generateJava(@Valid @RequestBody GenerateRequest request) {

        this.generatorService.generateJava(request);

        return BaseResponse.success(true);
    }

}

